export const Rem = () => {
	const whdef = 100 / 1920; 
	// 当前窗口的宽度
	const bodyWidth = document.body.clientWidth; 
	// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
	const rem = bodyWidth * whdef; 
	document.getElementsByTagName('html')[0].style.fontSize = rem + 'px';
}
window.addEventListener('load', Rem);
window.addEventListener('resize', Rem)

/**
 * 四舍五入 并保留小数点后指定位数，默认两位
 */
 export const floatRound = (num,digits =2) => {
	const scale = Math.pow(10,digits)
	return Math.round(num * scale) / scale
}
//生成uuid
export const guid = () => {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
            v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}
// guid() // "a1ca0f7b-51bd-4bf3-a5d5-6a74f6adc1c7"

export function $(selector) {
    return document.querySelector(selector)
}

//处理锁死的递归函数
export const lockFun = (obj,background,flag) => {
	obj.isDisable = flag
	if(obj.childrenData){
		obj.childrenData.map(item => {
			lockFun(item,background,flag)
		})
	}
} 

//将 "80%" 转换为 parentInt 80
export const perToParseInt = (str) => {
	//eslint-disable-next-line
	return parseInt(str.replace(/\"/g, ""))
}